package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.produce_team.IHandOverCheckView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.HandOverCheckModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IHandOverCheckModel;

public class HandOverCheckPresenter {
    private IHandOverCheckView view;
    private IHandOverCheckModel model;
    private Handler handler = new Handler();

    public HandOverCheckPresenter(IHandOverCheckView view) {
        this.view = view;
        this.model = new HandOverCheckModel();
    }

    public void handOverCheck() {
        model.handOverCheck(view.getConcessionAmount(), view.getConcessionReason(), view.getQualifiedAmount(), view.getReturnImgUrlList(), view.getReturnReason(), view.getWorkPartHandOverId(), new HandOverCheckModel.OnHandOverCheckListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.handOverCheckSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.handOverCheckFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
